# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=libvolk
pkgver=3.0.0
_cpufeaturesver=0.8.0
pkgrel=0
pkgdesc="Vector-Optimized Library of Kernels"
url="https://www.libvolk.org/"
# libvolk provides hand-written SIMD code. Hence, support needs to be manually
# added to new platforms. Currently only supported are:
arch="armv7 aarch64 x86_64"
license="LGPL-3.0-or-later"
depends="python3"
makedepends="cmake py3-mako boost-dev orc-dev samurai"
checkdepends="bash"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/gnuradio/volk/archive/v$pkgver.tar.gz
	cpu_features-$_cpufeaturesver.tar.gz::https://github.com/google/cpu_features/archive/v$_cpufeaturesver.tar.gz
	"
builddir="$srcdir/volk-$pkgver"

prepare() {
	default_prepare

	rm -r cpu_features
	ln -s "../cpu_features-$_cpufeaturesver" cpu_features

	# for test ...
	ln -s docs/AUTHORS_RESUBMITTING_UNDER_LGPL_LICENSE.md AUTHORS_RESUBMITTING_UNDER_LGPL_LICENSE.md
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "qa_volk_16ic_x2_dot_prod_16ic"
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

sha512sums="
52ebe13f27d3d9847db001d89ec66b16ee189a5d3dc8aafd5d31c8ba36f1a4986a75a40866ea65d37f34e05fb6daf19c89d4ba9b1af79d3859b6428f27b0a114  libvolk-3.0.0.tar.gz
43085d11f58f314d696276c8543561d411a4156aa546d1e14ed3d8adffded5818f1ad4259b3ad38bb5d4167bd9084f78c725eb53509999a2349a749b9eb47007  cpu_features-0.8.0.tar.gz
"
